by Keith McIntyre
In This Chapter
TAPI is an abbreviation for Telephony Application Programming Interface. As the name implies, TAPI enables developers to write applications that take advantage of services provided by telephony vendors. The services can be good ol Ma Bell services accessed over an analog modem or advanced telephony services provided by a proprietary Private Branch Exchange (PBX).
TAPI is one of the services defined by the Windows Open System Architecture (WOSA). It is a well-thought-out client interface and internal architecture that has proven to be powerful and extensible. As depicted in Figure 28.1, the TAPI architecture consists of TAPI-enabled applications and TAPI Service Providers. The TAPI-enabled applications talk to the Service Providers indirectly via the Telephony API. TAPI provides an abstraction that allows the applications to be written in a platform-independent fashion. The Service Providers are responsible for taking the platform-independent abstraction and implementing specializations (drivers) that control specific hardware devices.
Figure 28.1 provides a general description of the TAPI architecture. (Different versions of TAPI implement differing architectures underneath the covers. In particular, versions 1.4, 2, and 3 introduce drastic departures from previous versions.)
Figure 28.1 An abstraction of the TAPI architecture.
In this chapter, youll start by looking at an overview of TAPI. Next youll take a look at the history of TAPI and a peek at what the future of TAPI will offer. Youll then use both Assisted Telephony and Basic Telephony Services to write sample applications that allow an analog modem to dial an interactive voice call.
TAPI, the Telephony Application Programming Interface, enables a programmer to develop applications that interface with telephony systems ranging from a simple Plain Old Telephone Service (POTS) line to a modern Private Branch Exchange (PBX). TAPI can be incorporated into an application as an ancillary function. TAPI could, for example, enable an application to dial a phone number. Or an application can be written that is very TAPI-centric. Perhaps the application provides an interface to a PBX system whereby the user can store commonly dialed numbers, record greetings, page colleagues, and take dictation.
Four levels of service are provided by TAPI:
Assisted Telephony provides a short list of functions that allow non-telephony-centric applications to easily add the ability to dial outgoing calls to their feature set. Using Assisted Telephony in conjunction with VBA, one can add dialing capabilities into Microsoft Word documents or Excel spreadsheets. Assisted Telephony can also be used to add phone dialing to Visual C++/MFC applications you write with MSVC 6. Assisted Telephony only supports dialing numbers for interactive voice calls.
Currently, Assisted Telephony supports only two function calls:
TapiRequestMakeCall() works together with the Dialer.exe application provided with Windows 95 and Windows 98 to handle all the details of finding the right device on which to place the call, dialing the number, and providing a user interface from which the user can hang up the call.
TapiGetLocationInfo() provides a means of obtaining country and city code information that can be used when constructing the phone number given to TapiRequestMakeCall().
Previous versions of Assisted Telephony supported two additional functions:
These are no longer supported by Win32 applications and should not be used.
Basic Telephony Services is targeted at programmers who want to have increased control over the telephony operations their application provides but do not have to control advanced PBX functions.
The Basic Telephony Services are deliverable by all Service Providers regardless of the hardware employed. The abstraction provided by TAPI allows applications to be written that will run on different vendors hardware platforms. In a similar fashion to the way GDI made platform independent graphics possible, TAPI makes hardware-independent telephony software possible. (And as you will see later, TAPI provides an API negotiation mechanism that allows applications to run against different versions of TAPI as well.)
The services made available through the Basic Telephony Services include the following:
Address translation is concerned with generating a locale-specific version of a canonical address. A canonical address contains all the information required to uniquely identify an endpoint. This includes country code, area code, and the phone number. Canonical addresses start with a + character. Hence, +1 (619) 554-1400 would be a good representation of the telephone number for reaching Stellcom Incorporated located in San Diego, California (area code 619), USA (country code 1), with the phone number 554-1400.
The address translation process takes into account the current location the call is being placed from. The Modem applet contained in the Control Panel provides a Dialing Properties dialog. A tab in this dialog is titled My Locations. The associated user interface allows the user to establish a number of calling profiles each with independently specified settings for the current area code, country code, access number for dialing long distance or obtaining an outside line, and disabling call waiting. One can also specify a calling card number that should be used when placing long distance calls as well as specifying rules, based on area codes, as to when a call should be treated as long distance. Figure 28.2 shows the Dialing Properties dialog available with Windows 98.
Figure 28.2 The Dialing Properties dialog box.
Address translation takes a canonical address as input, applies the rules specified through the current I Am Dialing From setting in the Dialing Properties dialog, and generates a locale-specific dial string. The locale-specific string includes all the information such as the digit required to get to an outside line, the calling card number to which the call should be called, the area code, and so on. So the canonical number presented earlier might translate to something like T 9 5541400.
When you have a locale-specific dial string, you probably want to use it to place a call. Making calls is not a simple task when using Basic Telephony Service. As you will see later in the chapter, a significant amount of code is required to initialize TAPI, obtain a line handle that meets the required communications needs, negotiate a TAPI service level, and establish a call.